package jj.jjstudy.controller;

import jj.jjstudy.entity.User;
import jj.jjstudy.response.ResponseData;
import jj.jjstudy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {


    @Autowired
    private UserService userService;

    @RequestMapping(value = "inserUser",method = RequestMethod.POST)
    public ResponseData<Integer> inserUser(@RequestBody User user){

        return userService.inserUser(user);
    }



    @RequestMapping(value = "/updateUser" , method = RequestMethod.POST)
    public ResponseData<Integer> updateUser(@RequestBody User user){

        return  userService.updateUser(user);
    }


    @RequestMapping(value = "/delUser" , method = RequestMethod.POST)
    public ResponseData<Integer> delUser(@RequestParam(value = "user_id") String user_id){

        return  userService.delUser(user_id);
    }

    @RequestMapping(value = "/findUser" , method = RequestMethod.GET)
    public ResponseData<List<User>> findUser(@RequestParam(value = "user_name") String user_name){

        return  userService.findUser(user_name);
    }


}
